---
title: git-hooks
date: '2023-04-01 12:12:12'
tags: ['git', '工具']
draft: false
summary: 通过git-hooks钩子，在commit是触发eslint或者prettier来规范提交的代码
---

```json
{
  "gitHooks": {
    "pre-commit": "lint-staged"
  },
  "lint-staged": {
    "*.{js,jsx,less,md,json}": ["prettier --write"],
    "*.ts?(x)": ["prettier --parser=typescript --write"]
  }
}
```
